<?php
/**
 * Created by PhpStorm.
 * User: tengwei
 * Date: 2018/11/16
 * Time: 3:29 PM
 */
namespace common\sources\read\message;

use common\logics\message\IMessage;
use common\models\craftsman\SmsCode;

class MesgAccess implements IMesgAccess
{

    public function getSms($data)
    {
        // TODO: Implement smsInfo() method.
        return SmsCode::find()
            ->where(['phone' => $data['phone']])
            ->andFilterWhere(['between', 'sendtime', $data['today'], $data['endtoday']])
            ->asArray()
            ->count();
    }
    public function getVerifyCode($phone,$type)
    {
        return SmsCode::find()
            ->select('id,verifycode,sendtime')
            ->where(['phone' => $phone,'type' =>$type,'status'=>1])
            ->orderBy('sendtime DESC')
            ->asArray()
            ->one();
    }

}